﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using QLab.UX.Forms.Controls;

namespace QLab.UX.Forms
{
    public partial class ConsoleWindow : ToolWindow
    {
        private QLab.UX.Forms.Controls.Console console;

        public ConsoleWindow(ToolStripMenuItem toolStripMenuItem, DockPanel dockPanel)
            : base("Console", EnumsEngine.GetToolWindowName(ToolWindowType.Console), toolStripMenuItem, dockPanel)
        {
            InitializeComponent();
            InitializeComponentQLab();
        }

        private void InitializeComponentQLab()
        {
            console = new QLab.UX.Forms.Controls.Console();
            this.Controls.Add(console);
            console.Dock = DockStyle.Fill;
            this.console.CommandExecuted += new QLab.UX.Forms.Controls.Console.CommandExecutedDelegate(console_CommandExecuted);
        }

        void console_CommandExecuted(object sender, CommandExecutedEventArgs e)
        {
            this.OnCommandExecuted(e.Command);
        }

        protected override string GetPersistString()
        {
            return EnumsEngine.GetToolWindowName(ToolWindowType.Console);
        }

        public delegate void CommandExecutedEventHandler(object sender, CommandExecutedEventArgs e);
        public event CommandExecutedEventHandler CommandExecuted = null;
        private void OnCommandExecuted(string command)
        {
            if (this.CommandExecuted != null)
                this.CommandExecuted(this, new CommandExecutedEventArgs(command));
        }
    }
}
